package cn.itsource.dept.service.impl;

import cn.itsource.dept.domain.Employee;
import cn.itsource.dept.domain.EmployeeBo;
import cn.itsource.dept.domain.EmployeeVo;
import cn.itsource.dept.mapper.EmployeeMapper;
import cn.itsource.dept.service.IEmployeeService;
import cn.itsource.base.service.impl.IBaseServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xlh
 * @since 2023-01-16
 */
@Service
public class EmployeeServiceImpl extends IBaseServiceImpl<Employee> implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public List<Employee> findAll() {
        List<EmployeeBo> lists = employeeMapper.findnoeee();
        ArrayList<Employee> employeeList = new ArrayList<>();
        for(EmployeeBo list : lists){
            Employee employee = new Employee();
            BeanUtils.copyProperties(list,employee);
            employeeList.add(employee);
        }
        return employeeList;
    }

    @Override
    public List<EmployeeVo> countByDept() {
        return employeeMapper.countByDept();
    }
}
